gtkplacessidebar.c: add bookmark null checking
authorGeyslan G. Bem <geyslan@gmail.com>
Tue, 27 Apr 2021 14:42:55 +0000 (11:42 -0300)
committerGeyslan G. Bem <geyslan@gmail.com>
Tue, 27 Apr 2021 14:58:31 +0000 (11:58 -0300)
This fixes nautilus crash and perhaps other callers issues.
Nautilus (and sometimes glib) crashes with malformed URI inside of the
bookmarks file .config/gtk-3.0/bookmarks when it has no LABEL.

This is result from the closed glib MR #2065 analysis and agreement.
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2065#note_1091979

Signed-off-by: Geyslan G. Bem <geyslan@gmail.com>
gtk/gtkplacessidebar.c

index 43f03069d8ea4f1a77f65f69010d2b24b1f2369d..c57031be07df116bd07827627e28d9c352c7c937 100644 (file)
@@ -795,6 +795,10 @@ on_bookmark_query_info_complete (GObject      *source,
     {
       /* Don't add non-UTF-8 bookmarks */
       bookmark_name = g_file_get_basename (root);
+      if (bookmark_name == NULL)
+        {
+          goto out;
+        }
       if (!g_utf8_validate (bookmark_name, -1, NULL))
         {
           g_free (bookmark_name);